<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>融资报价维护</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<style>
.error{
	color:red;
}
</style>
<body class="iframeBody">
	<div class="Wrapper">
		<div id="pageInTab" class="pageInTab">
			<form id="scm_bsc_info_form">
				<div class="fieldset1 tabel_col tabel_col_s clearFix">
					<div class="caption">
						<span class="title">报价基础信息 </span>
					</div>
					<div class="fieldBox col_50">
						<div class="label">报价名称</div>
						<div class="field">												
							<input type="hidden" id="fncScmId" name="fncScmId" value="${fncScmId}">
							<input name="fncScmNm" id="fncScmNm" type="text"
									class="ui-textbox" value="${bscinfo.fncScmNm}" validate="{required:true}">			
								<%-- 	<span name="fncScmNm" id="fncScmNm" >${bscinfo.fncScmNm}</span>		
								<input type="hidden" id="fncScmId" name="fncScmId" value="${fncScmId}"> --%>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">融资机构名称</div>
						<div class="field">
							<span name="fncInsNm" id="fncInsNm" >${fncInsNm}</span>	
							<input type="hidden" id="fncInsId" name="fncInsId" value="${bscinfo.fncInsId}">
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">授信名称</div>
						<div class="field">
							<input name="crId" id="crId" type="text" class="ui-textbox" value="${crNm}">
							<input type="hidden" id="crIdVal" name="crIdVal" value="${bscinfo.crId}">
							<input type="hidden" id="abs" name="abs" value="${abs}">
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">产品名称</div>
						<div class="field">
							<input name="pdId" id="pdId" type="text" class="ui-textbox" value="${pdNm}">
							<input type="hidden" id="pdIdVal" name="pdIdVal" value="${bscinfo.pdId}">
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">计划封包日</div>
						<div class="field">
							<input name="stdt" id="stdt" type="text"
								class="ui-datepicker" value="${bscinfo.stdt}" validate="{required:true}">
								&nbsp;&nbsp; --- &nbsp;&nbsp;
							<input name="eddt" id="eddt" type="text"
								class="ui-datepicker" value="${bscinfo.eddt}" validate="{required:true}">
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">还款类别</div>
						<div class="field">
		                    <select name="rePyTpCd" id="rePyTpCd">
		                        <c:forEach items="${rePyTpCdLst}" var="item">
		                       		<c:choose>
			                       		<c:when test="${item.key == bscinfo.repyTp}">
			                        		<option value="${item.key}" selected="selected">${item.value}</option>
			                       		</c:when>
			                       		<c:otherwise>
			                        		<option value="${item.key}">${item.value}</option>
			                       		</c:otherwise>
		                       		</c:choose>
		                        </c:forEach>
		                    </select>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">业务类别</div>
						<div class="field">
		                    <select name="busType" id="busType">
		                        <c:forEach items="${busTypeLst}" var="busType">
		                       		<c:choose>
			                       		<c:when test="${busType.key == bscinfo.busType}">
			                        		<option value="${busType.key}" selected="selected">${busType.value}</option>
			                       		</c:when>
			                       		<c:otherwise>
			                        		<option value="${busType.key}">${busType.value}</option>
			                       		</c:otherwise>
		                       		</c:choose>
		                        </c:forEach>
		                    </select>
						</div>
					</div>
				</div>
				
				<div class="fieldset1 tabel_col tabel_col_s clearFix">
					<div class="caption">
						<span class="title">报价信息 </span>
					</div>
					<div class="fieldBox col_50">
						<div class="label">融资基数</div>
						<div class="field">
		                    <select name="fncCrdnlt" id="fncCrdnlt">
		                    	<c:choose>
			                    <c:when test="${bscinfo.fncCrdnlt == null or bscinfo.fncCrdnlt == ''} ">
			                    	<option value="" selected="selected">请选择</option>
			                       	<c:forEach items="${fncCrdnltCdLst}" var="item">
			                       		<c:choose>
				                       		<c:when test="${item.key == bscinfo.fncCrdnlt}">
				                        		<option value="${item.key}">${item.value}</option>
				                       		</c:when>
				                       		<c:otherwise>
				                        		<option value="${item.key}">${item.value}</option>
				                       		</c:otherwise>
			                       		</c:choose>
			                        </c:forEach>
			                    </c:when>
			                    <c:otherwise>			                    
			                    	<option value="">请选择</option>
			                       	<c:forEach items="${fncCrdnltCdLst}" var="item">
			                       		<c:choose>
				                       		<c:when test="${item.key == bscinfo.fncCrdnlt}">
				                        		<option value="${item.key}" selected="selected">${item.value}</option>
				                       		</c:when>
				                       		<c:otherwise>
				                        		<option value="${item.key}">${item.value}</option>
				                       		</c:otherwise>
			                       		</c:choose>
			                        </c:forEach>
		                        </c:otherwise>
		                        </c:choose>
		                    </select>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">打折率(%)</div>
						<div class="field">
								<input name="dcnRate" id="dcnRate" type="text"
									class="ui-textbox" value="${bscinfo.dcnRate}" validate="{number:true,max:100,min:0,decimallen:4}">
						</div>
					</div>
					
					<div class="fieldBox col_50">
						<div class="label">融资期限(月)</div>
						<div class="field">
								<input name="fncTrm" id="fncTrm" type="text"
									class="ui-textbox" value="${bscinfo.fncTrm}" ligerui="{type:'int'}" validate="{digits:true}">
						</div>
					</div>
					<div class="fieldBox col_50">
						
						<div class="label">是否涉及境外</div>
						<input id="wthrSupAbrVal" name="wthrSupAbrVal" type="hidden" value="${bscinfo.wthrSupAbr}">
						<div class="field">
							<select name="wthrSupAbr" id="wthrSupAbr" onchange="switchAbroadForm()">
		                       	<c:forEach items="${searchWthrKVList}" var="wthrSupAbr">
		                       		<c:choose>
			                       		<c:when test="${wthrSupAbr.key == bscinfo.wthrSupAbr}">
			                        		<option value="${wthrSupAbr.key}" selected="selected">${wthrSupAbr.value}</option>
			                       		</c:when>
			                       		<c:otherwise>
			                        		<option value="${wthrSupAbr.key}">${wthrSupAbr.value}</option>
			                       		</c:otherwise>
		                       		</c:choose>
		                        </c:forEach>
		                    </select>
						</div>
					</div>
					<div class="fieldBox col_50" id="s1">
						<div class="label">利率基准(%)</div>
						<div class="field">
							<input name="irtBs" id="irtBs" type="text"
									class="ui-textbox" value="${bscinfo.irtBs}" validate="{number:true,max:100,min:0,decimallen:4}">
						</div>
					</div>
					<div class="fieldBox col_50" id="s3">
						<div class="label">报价利率(%)</div>
						<div class="field">
							<input name="scmIntrt" id="scmIntrt" type="text"
									class="ui-textbox" value="${bscinfo.scmIntrt}" validate="{number:true,max:100,min:0,decimallen:4,required:true}">
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">利率是否浮动</div>
						<input id="irtTpcdVal" name="irtTpcdVal" type="hidden" value="${bscinfo.irtTpcd}">
						<div class="field">
							<select name="irtTpcd" id="irtTpcd" onchange="switchIrtForm()">
		                       	<c:forEach items="${searchWthrKVList}" var="item">
		                       		<c:choose>
			                       		<c:when test="${item.key == bscinfo.irtTpcd}">
			                        		<option value="${item.key}" selected="selected">${item.value}</option>
			                       		</c:when>
			                       		<c:otherwise>
			                        		<option value="${item.key}">${item.value}</option>
			                       		</c:otherwise>
		                       		</c:choose>
		                        </c:forEach>
		                    </select>
						</div>
					</div>			
					<div class="fieldBox col_50" title="intrtMtdcd">
						<div class="label">利率上浮方式</div>
						<div class="field">
		                    <select name="intrtMtdcd" id="intrtMtdcd">
		                       	<c:forEach items="${intrtMtdcdLst}" var="item">
		                        	<c:choose>
			                       		<c:when test="${item.key == bscinfo.intrtMtdcd}">
			                        		<option value="${item.key}" selected="selected">${item.value}</option>
			                       		</c:when>
			                       		<c:otherwise>
			                        		<option value="${item.key}">${item.value}</option>
			                       		</c:otherwise>
		                       		</c:choose>
		                        </c:forEach>
		                    </select>
						</div>
					</div>
					<div class="fieldBox col_50" id="s2">
						<div class="label">基准上浮比例(%)</div>
						<div class="field">
								<input name="bsFlotupRto" id="bsFlotupRto" type="text"
									class="ui-textbox" value="${bscinfo.bsFlotupRto}" validate="{number:true,max:100,min:0,decimallen:4}">
						</div>
					</div>					
					<div class="fieldBox col_50" title="prymMtd">
						<div class="label">调息方式</div>
						<div class="field">
		                    <select name="prymMtd" id="prymMtd">
		                       	<c:forEach items="${prymMtdLst}" var="item">
		                        	<c:choose>
			                       		<c:when test="${item.key == bscinfo.prymMtd}">
			                        		<option value="${item.key}" selected="selected">${item.value}</option>
			                       		</c:when>
			                       		<c:otherwise>
			                        		<option value="${item.key}">${item.value}</option>
			                       		</c:otherwise>
		                       		</c:choose>
		                        </c:forEach>
		                    </select>
						</div>
					</div>
					
				</div>	
				<!-- 担保信息  start  -->
				<div class="fieldset1 tabel_col tabel_col_s clearFix">
					<div class="caption">
						<span class="title">担保信息 </span>
					</div>
					<div class="fieldBox col_50">
						<div class="label">是否担保</div>
						<div class="field">
		                    <select name="isGuarantee" id="isGuarantee">
		                    	<option value="">--请选择--</option>
		                    	<c:forEach items="${sysYNList}" var="sysyn">
		                    	  <c:choose>
			                       		<c:when test="${sysyn.key == bscinfo.isGuarantee}">
			                        		<option value="${sysyn.key}" selected="selected">${sysyn.value}</option>
			                       		</c:when>
			                       		<c:otherwise>
			                        		<option value="${sysyn.key}">${sysyn.value}</option>
			                       		</c:otherwise>
		                       		</c:choose>
		                    	  
		                    	  
		                    	</c:forEach>
		                   </select><font color="red">*</font>
		                </div>
		             </div>
		             <div class="fieldBox col_50">
						<div class="label">担保主体</div>
						<div class="field">
		                   <input name="guaranteeBody" id="guaranteeBody" data-value="${bscinfo.guaranteeBody}"  placeholder="请选择"  ltype="combobox" >
		                </div>
		             </div>
		            <div class="fieldBox col_50">
						<div class="label">担保开始日</div>
						<div class="field">
		                    <input name="guaranteeStart" value="${bscinfo.guaranteeStart}" class="ui-datepicker" id="guaranteeStart" />
		                </div>
		             </div>
		            <div class="fieldBox col_50">
						<div class="label">担保到期日</div>
						<div class="field">
		                    <input name="guaranteeEnd" value="${bscinfo.guaranteeEnd}" class="ui-datepicker" id="guaranteeEnd"/>
		                </div>
		             </div>
		           <div class="fieldBox col_100">
						<div class="label">担保主体备注</div>
						<div class="field">
		                    <input name="guaranteeRemark" value="${bscinfo.guaranteeRemark}" id="guaranteeRemark" class="ui-textbox" />
		                </div>
		           </div>
				</div>
				<!-- 担保信息  end -->
				<div class="fieldset1 tabel_col tabel_col_s clearFix">
					<div class="caption">
						<span class="title">计费信息 </span>
						<div style="margin-left: auto;margin-right: 10px;width:200px;margin-top: -15px">
							<span id="scm_cost2_sv_btn_id"
								class="sq-button sq-button-round" onclick="addNewCost1();">新增
							</span>
							<span id="scm_cost2_del_btn_id"
								class="sq-button sq-button-round" onclick="deleteRow1();" >删除选中行
							</span>
						</div>
					</div>
					<div class="fieldBox col_100">
							<div id="cost1" class="sq-grid">
							</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">方案XIRR(%)</div>
						<div class="field">
								<input name="irr" id="irr" type="text"
									class="ui-textbox" value="${bscinfo.irr}" validate="{number:true,max:100,min:0,decimallen:4}">
						</div>
					</div>
				</div>
				
				<div class="fieldset1 tabel_col tabel_col_s clearFix" id="abdform">
					<div class="caption">
						<span class="title">境外成本</span>
					</div>
					<div class="fieldBox col_50">
						<div class="label">是否存在汇率风险</div>
						<div class="field">
							<select name="exstExrtRsk" id="exstExrtRsk">
		                       	<c:forEach items="${searchWthrKVList}" var="item">
		                       		<c:choose>
			                       		<c:when test="${item.key == bscinfo.exstExrtRsk}">
			                        		<option value="${item.key}" selected="selected">${item.value}</option>
			                       		</c:when>
			                       		<c:otherwise>
			                        		<option value="${item.key}">${item.value}</option>
			                       		</c:otherwise>
		                       		</c:choose>
		                        </c:forEach>
		                    </select>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">是否存在利率风险</div>
						<div class="field">
							<select name="exstIntrtRsk" id="exstIntrtRsk">
		                       	<c:forEach items="${searchWthrKVList}" var="item">
		                       		<c:choose>
			                       		<c:when test="${item.key == bscinfo.exstIntrtRsk}">
			                        		<option value="${item.key}" selected="selected">${item.value}</option>
			                       		</c:when>
			                       		<c:otherwise>
			                        		<option value="${item.key}">${item.value}</option>
			                       		</c:otherwise>
		                       		</c:choose>
		                        </c:forEach>
		                    </select>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">汇率风险承包方</div>
						<div class="field">
								<input name="exrtRskCntr" id="exrtRskCntr" type="text"
									class="ui-textbox" value="${bscinfo.exrtRskCntr}">
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">利率风险承包方</div>
						<div class="field">
								<input name="intrtRskCntr" id="intrtRskCntr" type="text"
									class="ui-textbox" value="${bscinfo.intrtRskCntr}">
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">是否承做汇率掉期</div>
						<div class="field">
							<select name="cmtExrtSwp" id="cmtExrtSwp">
		                       	<c:forEach items="${searchWthrKVList}" var="item">
		                       		<c:choose>
			                       		<c:when test="${item.key == bscinfo.cmtExrtSwp}">
			                        		<option value="${item.key}" selected="selected">${item.value}</option>
			                       		</c:when>
			                       		<c:otherwise>
			                        		<option value="${item.key}">${item.value}</option>
			                       		</c:otherwise>
		                       		</c:choose>
		                        </c:forEach>
		                    </select>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">是否承做利率掉期</div>
						<div class="field">
							<select name="cmtIntrtSwp" id="cmtIntrtSwp">
		                       	<c:forEach items="${searchWthrKVList}" var="item">
		                       		<c:choose>
			                       		<c:when test="${item.key == bscinfo.cmtIntrtSwp}">
			                        		<option value="${item.key}" selected="selected">${item.value}</option>
			                       		</c:when>
			                       		<c:otherwise>
			                        		<option value="${item.key}">${item.value}</option>
			                       		</c:otherwise>
		                       		</c:choose>
		                        </c:forEach>
		                    </select>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">汇率掉期银行</div>
						<div class="field">
								<input name="exrtSwpBnk" id="exrtSwpBnk" type="text"
									class="ui-textbox" value="${bscinfo.exrtSwpBnk}">
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">利率掉期银行</div>
						<div class="field">
								<input name="intrtSwpBnk" id="intrtSwpBnk" type="text"
									class="ui-textbox" value="${bscinfo.intrtSwpBnk}">
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">汇率掉期费率(%)</div>
						<div class="field">
								<input name="exrtSwpFeert" id="exrtSwpFeert" type="text"
									class="ui-textbox" value="${bscinfo.exrtSwpFeert}" validate="{number:true,max:100,min:0,decimallen:4}">
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">利率掉期费率(%)</div>
						<div class="field">
								<input name="intrtSwpFeert" id="intrtSwpFeert" type="text"
									class="ui-textbox" value="${bscinfo.intrtSwpFeert}" validate="{number:true,max:100,min:0,decimallen:4}">
						</div>
					</div>					
				</div>	
				
				<div class="fieldset1 tabel_col tabel_col_s clearFix">
					<div class="fieldBox col_100">
						<div class="label">备注</div>
						<div class="field">
                			<textarea class="l-textarea" id="rmrk" style="width:100%">${bscinfo.rmrk}</textarea>
						</div>
					</div>
				</div>			
			</form>
		</div>

		<div class="btnsBox">
			<span id="scm_bsc_info_add_btn_id" class="sq-button sq-button-round" >保存</span>
		</div>
	</div>

	<script type="text/javascript">
	//add 保证金使用方式  by gengchunlan 20180627
	var mrgnUseMtdJSON = [];
	<c:if test="${not empty mrgnUseMtdJSON}"> mrgnUseMtdJSON = ${mrgnUseMtdJSON}; </c:if> 
	var feeListJSON = [];
	<c:if test="${not empty feeListJSON}"> feeListJSON = ${feeListJSON}; </c:if> 
	
	var combdata1,combdata2,griddata1,griddata2;
	    
	    // 验证值小数位数不能超过指定位数param  郭志强20170810
	    $.validator.addMethod("decimallen", function(value, element, param) {
	        var decimallen =eval("/^-?\\d+(\\.\\d{0," + param + "})?$/"); 
	        return this.optional(element) || (decimallen.test(value));
		}, "小数位数不能超过{0}位");
	    
		$(function () {
			
			//REQ-15103  担保主体多选
			$("#guaranteeBody").ligerComboBox({ isShowCheckBox: true, isMultiSelect: true,
		     	   data: ${guaranteeBodyLst},
		            slide: false,
		            valueField: 'key', textField: 'value',
		            valueFieldID: 'guaranteeBody'
		      });
			
			
			f_initDatePicker();
			f_initCostData1();
			initCrLstForm();
			initPdList();
			//hideIrtForm();
			initIrtForm();
			initAbroadForm();
        	$("#scm_bsc_info_form").ligerForm({
        		validate:true
            });
			saveScmBaseBtnEvent();
		});
		
	    function f_initCostData1()
	    { 
			var fncScmId = $("#fncScmId").val();
			griddata1 = $("#cost1").ligerGrid({
			    	url: '<%=path%>/rfbase/scmbaseinfo/initChrgList.do?fncScmId='+fncScmId,
			    	method : 'get',
	                columns: [
		                { display: '费用名称', name: 'costNm', minWidth: 150 ,enabledSort:true,
		            	       validate:{required:true,minlength:1},
		            	editor: 
		            	 {
		                    type: 'select',
		                    data: feeListJSON,
		                    isMultiSelect: false,isShowCheckBox: false,
		                    valueField: 'key',
		                    textField: 'value'
				          },
			                render: function (item) {
			                	console.log(item);
			                	return item.costNm;
			                }
		                },
		                { display: '是否保证金', width: 100, name: 'mrgnIs',type:'text',
			                  editor: { type: 'select', 
										data: [
						                    { value: '否', key: '0' },
						                    { value: '是', key: '1' }
						                ],
										valueField: 'key', textField: 'value' },
		                    	render: function (item)
			                    {
			                        if (parseInt(item.mrgnIs) == 1) return '是';
			                        return '否';
			                    }
			                },
			                { display: '保证金到期处理方式', name: 'mrgnUseMtd', minWidth: 150 ,enabledSort:true,
			            	       validate:{required:true,minlength:1},
			            	editor: 
			            	 {
			                    type: 'select',
			                    data: mrgnUseMtdJSON,
			                    isMultiSelect: false,isShowCheckBox: false,
			                    valueField: 'key',
			                    textField: 'value'
					          },
				                valueField: 'mrgnUseMtd',
				                textField: 'mrgnUseMtdDes',
				                render: function (item) {
				                    return item.mrgnUseMtdDes;
				                }
			                },
		                { display: '费用比例(%)', width: 150, name: 'costPct',type:'text',
		                    editor: { type: 'text' }
		                },
		                { display: '费用金额', name: 'costAmt', width: 150, type: 'float', editor: { type: 'float'} }, 
	                { display: '是否计入首付款', name: 'costInTpCd',width: 150,
		                    editor: { type: 'select', 
								data: [
				                    { value: '首付款', key: '1' },
				                    { value: '分期付款', key: '2' },
				                    { value: '一次性付款', key: '3' }
				                ],
								valueField: 'key', textField: 'value' },
	                    render: function (item)
	                    {
	                        if (parseInt(item.costInTpCd) == 1) return '首付款';
	                        if (parseInt(item.costInTpCd) == 2) return '分期付款'; 
	                        if (parseInt(item.costInTpCd) == 3) return '一次性付款';
	                        return '分期付款';
	                    }
	                },
	                { display: '首付款是否坐扣', name: 'wthrDdct',width: 150,
	                    editor: { type: 'select', 
									data: [
					                    { value: '否', key: '0' },
					                    { value: '是', key: '1' },
					                    { value: '默认已付', key: '2' }
					                ],
									valueField: 'key', textField: 'value' },
	                    render: function (item)
	                    {
	                        if (parseInt(item.wthrDdct) == 1) return '是';
	                        if (parseInt(item.wthrDdct) == 2) return '默认已付';
	                        return '否';
	                    }
	                },
	                { display: '预计付款时间', name: 'prePayDate', type: 'date',render:renderDate,format: 'yyyy-MM-dd',editor: { type: 'date' } },
	                { display: '备注', name: 'rmrk', isSort: false,
	                    editor: { type: 'text' }
	                } 
	                ],
	                onSelectRow: function (rowdata, rowindex)
	                {
	                    $("#txtrowindex").val(rowindex);
	                },
	                enabledEdit: true, isScroll: false, 
	                onBeforeEdit: f_onBeforeEdit,
	                onBeforeSubmitEdit: f_onBeforeSubmitEdit,
	                width: '100%',
	    	        root:'Rows',
	    	        record:'Total',
	    	        hideLoadButton : true,
	    	        width: '100%',
	    	        height:'100%',
	    	        heightDiff:-2,
	    	        checkbox:true,
	    	        rownumbers:true
	            }); 	    
	    }

	    //是否计入首付款为‘是’的时候，“是否坐扣”可编辑 默认0
	    function f_onBeforeEdit(e){
	        var manager = $("#cost1").ligerGetGridManager();
			var rowdata = manager.getRow(e.rowindex);
			var costin = rowdata.costInTpCd;
	        if (e.column.name == "wthrDdct"){
	        	if(costin == 1){
	        		return true;
	        	}else{
	        		return false;
	        	}
	        }
	    }
        function f_onBeforeSubmitEdit(e)
        { 
        	var manager = $("#cost1").ligerGetGridManager();
 		    var rowdata = manager.getRow(e.rowindex);
            var payval = e.value;
            if (e.column.name == "costPct")
            {          	
            	if($.isNumeric(Number(payval))){
            		var len = payval.substring(payval.indexOf(".")+1,payval.length).length;
            		var intval = payval;
            		if(payval.indexOf(".")>0){
            			intval = payval.substring(0,payval.indexOf("."));
            		}
            		if(len>6 || intval>99){
	            		alert("数字不能大于100且小数位不能超过6位!");
	            		return false;
            		}
            		//费用比例（%）费用金额只能填一项
            		if(payval !=null && payval !="" && payval !="0"&& rowdata.costAmt !=null && rowdata.costAmt !=""){
                 	    alert("计费信息中费用比例（%）和费用金额只能填写一项，请重新填写！");
         	           	return false;
                    }
            		return true;
            	}else{
            		alert("请输入数字!");
            		return false;
            	}     	
            }
            //费用比例（%）费用金额只能填一项
            if (e.column.name == "costAmt")
            {          	
             	 if( payval !=null && payval !="" && rowdata.costPct !=null && rowdata.costPct !=""&& rowdata.costPct !="0"){
             	    alert("计费信息中费用比例（%）和费用金额只能填写一项，请重新填写！");
     	           	return false;
                }
            }
            return true;
        }
        function deleteRow1()
        { 
        	griddata1.deleteSelectedRow();
        }   
		
        function addNewCost1()
        {
        	griddata1.addRow({});
        } 
		
        function f_initDatePicker(){
        	var stdts = $("#stdt").val();
        	var eddts = $("#eddt").val();
        	console.log(stdts+"___"+eddts);

    		var stDateStr = "";
    		if(null != stdts && stdts != ""){
            	$("#stdt").ligerDateEditor({ 
            		showTime: true, labelWidth: 100, labelAlign: 'left' ,format: 'yyyy-MM-dd',
            		onChangeDate : function(value){
            			$("#stdt").val(value);
            		}
            	});
    			var date = new Date(stdts);
    			stDateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
            	$("#stdt").ligerGetDateEditorManager().setValue(stDateStr);
    		}
    		var edDateStr = "";
    		if(null != eddts && eddts !=""){
            	$("#eddt").ligerDateEditor({ 
            		showTime: true, labelWidth: 100, labelAlign: 'left' ,format: 'yyyy-MM-dd',
            		onChangeDate : function(value){
            			$("#eddt").val(value);
            		}
            	});
    			var date = new Date(eddts);
    			edDateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
            	$("#eddt").ligerGetDateEditorManager().setValue(edDateStr);
    		}
        }
        
        function initCrLstForm(){
        	var fncInsId =$("#fncInsId").val();
        	combdata1 = $("#crId").ligerComboBox({ 
			        url:'<%=path%>/rfbase/scmbaseinfo/initCrList.do?insId='+fncInsId,
			        ajaxType :'GET', 
			        valueField: 'crId', textField: 'crNm',
					columns: [
		                { header: '授信编号', name: 'crId', width: 140 }, 
		                { header: '授信名称', name: 'crNm', width: 120 },
		                { header: '授信主体', name: 'crSbj', width: 120 },
		            ], 
		            width: 200,
		            selectBoxWidth: 480, selectBoxHeight: 240,
		            onChangeValue: function (newvalue){
		            	if(newvalue != null && newvalue != ""){
		            		var cridval = $("#crId").ligerGetComboBoxManager().getValue()
		            		$("#crIdVal").val(cridval);
		            		initPdList();
		            	}
		            }
                });
        }
        
        function initPdList(){
     	   var instid = $("#fncInsId").val();
   		   var cridval = $("#crId").ligerGetComboBoxManager().getValue()
     	   combdata2 = $("#pdId").ligerComboBox({
               columns: [
		            { header: '授信编号', name: 'crId', width: 140}, 
	                { header: '产品编号', name: 'pdId', width: 140}, 
	                { header: '产品名称', name: 'pdNm', width: 120},
	               ],
	            url:'<%=path%>/rfbase/scmbaseinfo/initPdList.do?insId='+instid+'&crid='+cridval,
	            ajaxType :'GET',
	            width: 200, slide: false,
	            selectBoxWidth: 480, selectBoxHeight: 240,
	            valueField: 'hid', textField: 'pdNm',
	            onChangeValue: function (newvalue){
	            	if(newvalue != null && newvalue != ""){
	            		var pdidval = $("#pdId").ligerGetComboBoxManager().getValue()
	            		console.log(pdidval);
	            		$("#pdIdVal").val(pdidval);
	            	}
	            }    
	       });
        }
    	//格式化时间
    	function renderDate(rowdata, index, value){
    		var dateStr = "";
    		if(null != value){
    			var date = new Date(value);
    			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
    		}
    		return dateStr;
    	}
        
        function switchIrtForm(){
        	var irtTpcd = $("#irtTpcd").val();
        	if(irtTpcd=="1"){
        		showIrtForm();
        	}
        	if(irtTpcd=="0"){
        		hideIrtForm();
        	}
        }
        
        function showIrtForm(){
        	$("#s2").show();
        	$("[title=prymMtd]").show();
        	$("[title=intrtMtdcd]").show();
        }
        
        function hideIrtForm(){
        	$("#s2").hide();
        	$("[title=prymMtd]").hide();
        	$("[title=intrtMtdcd]").hide();
        }
        
        function switchAbroadForm(){
        	var wthrSupAbr = $("#wthrSupAbr").val();
        	if(wthrSupAbr=="1"){
        		showAbroadForm();
        	}
        	if(wthrSupAbr=="0"){
        		hideAbroadForm();
        	}
        }
        
        function showAbroadForm(){
			$("#abdform").show();
        }
        
        function hideAbroadForm(){
			$("#abdform").hide();
        }
        
        //保存事件
        function saveScmBaseBtnEvent(){
        	$("#scm_bsc_info_add_btn_id").click(function(event) {
                var form = liger.get("scm_bsc_info_form");
                var scmIntrtval = $("#scmIntrt").val();
                if (!form.valid()|| (scmIntrtval=='0.0000'||scmIntrtval=='0')) {
                	if(scmIntrtval=='0.0000'||scmIntrtval=='0'){
                		$("#scmIntrt").parent().addClass("l-text-invalid");
                	}
                	UIUtils.alertWarning(LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO);
                    return false; //验证不通过，不执行以下代码
                }
//              2018-06-08
                if (!form.valid()|| scmIntrtval<0.0000) {
                	alert("报价利率必须为正数！");
                	return false;
                }
                var manager = $("#cost1").ligerGetGridManager();
                var rows = manager.rows; 
                for (var i = 0; i < rows.length; i++) {
                	 //费用名称含保证金,是否保证金，为是;
                	 if(rows[i].mrgnIs=='undefined'|| rows[i].mrgnIs==null || rows[i].mrgnIs==''){
                		 if(rows[i].costNm.indexOf("保证金")!=-1){
                			 if(confirm("计费信息中第"+(i+1)+"行【费用名称】是保证金时,【是否保证金】为否！确认继续么？")==false){
                				 return false; 
                			 }
                		 }
                	 }else{
                		 if(rows[i].mrgnIs=='0'){
                    		 if(rows[i].costNm.indexOf("保证金")!=-1){
                    			 if(confirm("计费信息中第"+(i+1)+"行【费用名称】是保证金时,【是否保证金】为否！确认继续么？")==false){
                    				 return false;
                    			 }
                    		 }
                    	 } 
                	 }//end if
                	if(( rows[i].costNm != null &&  rows[i].costNm != "")&&(rows[i].costPct =='undefined' || rows[i].costPct == null || rows[i].costPct == ''|| rows[i].costPct == '0')&&(rows[i].costAmt =='undefined' || rows[i].costAmt == null || rows[i].costAmt == ''|| rows[i].costAmt == '0')){
                   	 $.ligerDialog.warn("计费信息中第"+(i+1)+"行费用金额和费用比例至少维护一项！");
                   	 return false;
                    }
                }
                var beginDate=$("#stdt").val();  
                var endDate=$("#eddt").val();  
				console.log(beginDate+"___"+endDate);
                var d1 = new Date(beginDate.replace(/\-/g, "\/"));  
                var d2 = new Date(endDate.replace(/\-/g, "\/"));  
				console.log(d1+"___"+d2);
                 if(beginDate!=""&&endDate!=""&&d1 >=d2)  
                {  
                 alert("开始时间不能大于结束时间！");  
                 return false;  
                }
                var absval = $("#abs").val();
                var cridval = $("#crId").val();
                if(absval != null && absval != "" && absval == "0" && (cridval == null || cridval == "")){
                	alert("非ABS机构必须维护授信！");
                	return false;
                }
                var intrtMtdcdVal = $("#intrtMtdcd").val();
                var bsFlotupRtoVal = $("#bsFlotupRto").val();
            	var irtTpcdVal = $("#irtTpcd").val();
				console.log(intrtMtdcdVal+"___"+bsFlotupRtoVal+"___"+irtTpcdVal);
				if(irtTpcdVal=="1"){//modify by gengchunlan 20190121
	                if(intrtMtdcdVal != null && bsFlotupRtoVal != null 
	                		&& parseFloat(bsFlotupRtoVal) >=0 && intrtMtdcdVal != "1"){                	
	                }else{
	                	alert("当前报价存在利率浮动，请维护正确的利率上浮方式和基准利率上浮比例！！");
	                	return false;
	                }
				}
				//add 担保信息必填 校验  by gengchunlan 20191018
				var isGuarantee =$("#isGuarantee").val();
				if(null == isGuarantee || ""==isGuarantee ){
					alert("请维护 是否担保  选项！");
                	return false;
				}else{
					if('1'==isGuarantee){//是否担保为是，担保主体 /担保开始/担保到期 必填校验
						
						var guaranteeBody=$('#guaranteeBody').ligerComboBox().getValue();
					    if(null == guaranteeBody || ""==guaranteeBody ){
					    	alert("请维护 担保主体  选项！");
		                	return false;
					    }
					    var guaranteeStart = $('#guaranteeStart').val();//担保开始日期
					    var guaranteeEnd = $('#guaranteeEnd').val();//担保到期日期
					   
					    if(null == guaranteeStart || ""==guaranteeStart){
					    	alert("请维护 担保开始日  选项！");
		                	return false;
					    }
					    if(null == guaranteeEnd || "" ==guaranteeEnd){
					    	alert("请维护 担保到期日  选项！");
		                	return false;
					    }
					    var guaS = new Date(guaranteeStart.replace(/\-/g, "\/"));  
		                var guaE = new Date(guaranteeEnd.replace(/\-/g, "\/"));  
		                
					    if(guaS>guaE){
					    	alert("担保开始日不能大于担保到期日，请核查！");
		                	return false;	
					    }
					    
					    if('2'== guaranteeBody || '5'== guaranteeBody ){//担保主体=万钧及其他⾼ 管】or【担保主体=其他】时   担保主体备注 必填校验
					    	var guaranteeRemark =$('#guaranteeRemark').val();
					        if(null == guaranteeRemark || ""==guaranteeRemark){
					        	alert("请维护 担保主体备注  选项！");
			                	return false;
					        }
					    }
					}
				}
				//end by gengchunlan 20191018
                save();
            });
        };
    	
        function save()
        {   
            var data = $("form").serializeArray();
			var rmrkval = JSON.stringify($("#rmrk").val());
			var guaranteeBody=$('#guaranteeBody').ligerComboBox().getValue();
			var guaranteeBody=JSON.stringify(guaranteeBody);
			
            var jsondata = '{rmrk:'+rmrkval+',griddata1:'+JSON.stringify(griddata1.getData())+',formdata:'+JSON.stringify(data)+',guaranteeBody:'+guaranteeBody+'}';
			console.log(JSON.stringify(jsondata));
            $.ajax({
            	   type: "POST",
            	   url: "<%=path%>/rfbase/scmbaseinfo/modifyScmBscData.do",
            	   contentType: 'application/json',
            	   data: JSON.stringify(jsondata),
            	   dataType:"json",
            	   success: function(data){
            		 if(data.nmcnt > 0){
            			 alert("报价名称已存在，请修改报价名称！");
            			 return;
            		 }
            		 if(data.result != '0000'){alert('报价修改失败！');}
            		 else{
            			 alert( "报价修改成功!");
            			 var TAB=top.mainApp.parentTab;
            	         var currentTabid=TAB.getSelectedTabItemID();
            			 top.tab.removeTabItem(currentTabid);	
        			 }
            	   }
            	});
        }
        function initIrtForm(){
        	var irtTpcd = $("#irtTpcdVal").val();
        	if(irtTpcd=="1"){
        		showIrtForm();
        	}
        	if(irtTpcd=="0"){
        		hideIrtForm();
        	}
        }
        
        function initAbroadForm(){
        	var wthrSupAbr = $("#wthrSupAbrVal").val();
        	if(wthrSupAbr=="1"){
        		showAbroadForm();
        	}
        	if(wthrSupAbr=="0"){
        		hideAbroadForm();
        	}
        }
	</script>
</body>
</html>
